home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 15 / macformat_15.iso / C de cerca / Codewarrior Lite / MacOS Support / Headers / ANSI Headers / iomanip < prev    next >
Text File  |  1995-12-29  |  2KB  |  107 lines

  1. // iomanip standard header
  2. #ifndef _IOMANIP_
  3. #define _IOMANIP_
  4. #include <istream>
  5. #include <ostream>
  6.  
  7. #if __MWERKS__
  8. #pragma options align=mac68k
  9.  
  10. #if __CFM68K__ && __USING_IMPORTED_ANSI__
  11. #pragma import on
  12. #endif
  13. #endif
  14.  
  15.         // template class smanip
  16. template<class _T> class smanip {
  17. public:
  18.     smanip(ios& (*_F)(ios&, _T), _T _A)
  19.         : _Pf(_F), _Manarg(_A) {}
  20.     ios& (*_Pf)(ios&, _T);
  21.     _T _Manarg;
  22.     };
  23. template<class _T> inline
  24.     istream& operator>>(istream& _I, const smanip<_T>& _M)
  25.     {    // apply manipulator to input stream
  26.     _TRY_BEGIN
  27.         (*_M._Pf)(_I, _M._Manarg);
  28.     _CATCH_ALL
  29.         _I.setstate(ios::failbit);
  30.     _CATCH_END
  31.     return (_I);
  32.     }
  33. template<class _T> inline
  34.     ostream& operator<<(ostream& _O, const smanip<_T>& _M)
  35.     {    // apply manipulator to output stream
  36.     _TRY_BEGIN
  37.         (*_M._Pf)(_O, _M._Manarg);
  38.     _CATCH_ALL
  39.         _O.setstate(ios::failbit);
  40.     _CATCH_END
  41.     return (_O);
  42.     }
  43.         // template class imanip
  44. template<class _T> class imanip {
  45. public:
  46.     imanip(istream& (*_F)(istream&, _T), _T _A)
  47.         : _Pf(_F), _Manarg(_A) {}
  48.     istream& (*_Pf)(istream&, _T);
  49.     _T _Manarg;
  50.     };
  51. template<class _T> inline
  52.     istream& operator>>(istream& _I, const imanip<_T>& _M)
  53.     {    // apply input manipulator to input stream
  54.     _TRY_BEGIN
  55.         (*_M._Pf)(_I, _M._Manarg);
  56.     _CATCH_ALL
  57.         _I.setstate(ios::failbit);
  58.     _CATCH_END
  59.     return (_I);
  60.     }
  61.         // template class omanip
  62. template<class _T> class omanip {
  63. public:
  64.     omanip(ostream& (*_F)(ostream&, _T), _T _A)
  65.         : _Pf(_F), _Manarg(_A) {}
  66.     ostream& (*_Pf)(ostream&, _T);
  67.     _T _Manarg;
  68.     };
  69. template<class _T> inline
  70.     ostream& operator<<(ostream& _O, const omanip<_T>& _M)
  71.     {    // apply manipulator to output stream
  72.     _TRY_BEGIN
  73.         (*_M._Pf)(_O, _M._Manarg);
  74.     _CATCH_ALL
  75.         _O.setstate(ios::failbit);
  76.     _CATCH_END
  77.     return (_O);
  78.     }
  79.         // instantiations
  80. smanip<ios::fmtflags> resetiosflags(ios::fmtflags);
  81. smanip<ios::fmtflags> setiosflags(ios::fmtflags);
  82. smanip<int> setbase(int);
  83. smanip<int> setfill(int);
  84. smanip<int> setprecision(int);
  85. smanip<int> setw(int);
  86.  
  87. #if __MWERKS__
  88. #if __CFM68K__ && __USING_IMPORTED_ANSI__
  89. #pragma import reset
  90. #endif
  91.  
  92. #pragma options align=reset
  93. #endif
  94.  
  95. #endif
  96.  
  97. /*
  98.  * Copyright (c) 1994 by P.J. Plauger.  ALL RIGHTS RESERVED. 
  99.  * Consult your license regarding permissions and restrictions.
  100.  */
  101.  
  102. /* Change log:
  103.  *94June04 PlumHall baseline
  104.  *94Sept30 Applied diffs for Fri Aug 26 00:52:06 1994
  105.  *94Oct07 Inserted MW changes.
  106.  */
  107.